package org.example.greenhouse.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.example.greenhouse.entity.Device;
import org.example.greenhouse.result.Result;
import org.example.greenhouse.service.DeviceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@CrossOrigin
@RestController
@RequestMapping("/Device")
@Api(tags = "设备管理")
public class DeviceController {

    @Autowired
    private DeviceService deviceService;

    @ApiOperation("新增设备")
    @PostMapping("/addDevice")
    public Result addDevice(@RequestBody Device device) {
        return deviceService.addDevice(device);
    }

    @ApiOperation("根据大棚 ID 获取设备信息")
    @GetMapping("/getInfoByGreenHouseId")
    public Result getDevicesByGreenHouseId(@RequestParam Long greenHouseId) {
        return deviceService.getDevicesByGreenHouseId(greenHouseId);
    }
}